Skip to content

feat: add easter egg CPR for sparkline pulse#1865

Merged
danielroe merged 3 commits intonpmx-dev:mainfrom
graphieros:main
Mar 3, 2026
Merged

feat: add easter egg CPR for sparkline pulse#1865
danielroe merged 3 commits intonpmx-dev:mainfrom
graphieros:main

Conversation

@graphieros
Copy link
Contributor

This one is for fun

Feel free to improve it, or ignore if it's over the top ^^

@vercel
Copy link

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 3, 2026 7:12am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 3, 2026 7:12am
npmx-lunaria Ignored Ignored Mar 3, 2026 7:12am

Request Review

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 27.27273% with 32 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Package/WeeklyDownloadStats.vue 27.27% 27 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d02f00d and 4a6ec5b.

📒 Files selected for processing (1)
  • app/components/Package/WeeklyDownloadStats.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/Package/WeeklyDownloadStats.vue

📝 Walkthrough

Walkthrough

A Vue component (WeeklyDownloadStats.vue) was modified to add an Easter egg triggered by the arrow-key sequence Up, Right, Left, Up, Left, Right entered within a 1500 ms window. Key presses are captured via onKeyDown, validated stepwise, and reset on timeout or incorrect input; a full match calls layEgg() which toggles an eggPulse state. The sparkline configuration now uses dynamic showPulse/isLoop values and the DOM wraps the sparkline with an egg-pulse-target element. New CSS adds egg-pulse, heartbeat keyframes and a prefers-reduced-motion guard.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is related to the changeset; it mentions adding an easter egg feature as a fun addition, which aligns with the code changes that implement an arrow-key pattern easter egg.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/components/Package/WeeklyDownloadStats.vue (2)

255-280: Ignore arrow-key input when focus is inside editable fields.

At Line 255/264/273, the handler runs globally. This can accidentally trigger the easter egg while users navigate text inputs or editable regions.

Suggested refactor
+function isEditableTarget(target: EventTarget | null): boolean {
+  if (!(target instanceof HTMLElement)) return false
+  return (
+    target.isContentEditable
+    || target.tagName === 'INPUT'
+    || target.tagName === 'TEXTAREA'
+    || target.tagName === 'SELECT'
+  )
+}
+
 onKeyDown(
   'ArrowUp',
   e => {
-    if (!keyboardShortcuts.value) return
+    if (!keyboardShortcuts.value || isEditableTarget(e.target)) return
     pushEasterEggKey('arrowup')
   },
   { dedupe: true },
 )

282-295: Clear pulse timer across retriggers and on unmount.

At Line 293, a new timeout is created each pulse, but previous ones are not cancelled. Rapid retriggers can cut animations short, and cleanup on unmount is safer.

Suggested refactor
 const eggPulse = ref(false)
+let eggPulseTimeout: ReturnType<typeof window.setTimeout> | undefined

 function playEggPulse() {
   eggPulse.value = false
   void document.documentElement.offsetHeight
   eggPulse.value = true

-  window.setTimeout(() => {
+  clearTimeout(eggPulseTimeout)
+  eggPulseTimeout = window.setTimeout(() => {
     eggPulse.value = false
   }, 900)
 }

 onBeforeUnmount(() => {
   resetEasterEgg()
+  clearTimeout(eggPulseTimeout)
 })

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 970d141 and d4f51ee.

📒 Files selected for processing (1)
  • app/components/Package/WeeklyDownloadStats.vue

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/components/Package/WeeklyDownloadStats.vue (1)

255-280: Consider collapsing duplicated arrow-key handlers.

Line 255-Line 280 repeats the same logic three times. A tiny helper keeps behaviour identical while reducing drift risk.

Refactor sketch
+function bindEasterEggKey(code: 'ArrowUp' | 'ArrowRight' | 'ArrowLeft', key: CheatKey) {
+  onKeyDown(
+    code,
+    () => {
+      if (!keyboardShortcuts.value) return
+      pushEasterEggKey(key)
+    },
+    { dedupe: true },
+  )
+}
+
-onKeyDown(
-  'ArrowUp',
-  e => {
-    if (!keyboardShortcuts.value) return
-    pushEasterEggKey('arrowup')
-  },
-  { dedupe: true },
-)
-
-onKeyDown(
-  'ArrowRight',
-  e => {
-    if (!keyboardShortcuts.value) return
-    pushEasterEggKey('arrowright')
-  },
-  { dedupe: true },
-)
-
-onKeyDown(
-  'ArrowLeft',
-  e => {
-    if (!keyboardShortcuts.value) return
-    pushEasterEggKey('arrowleft')
-  },
-  { dedupe: true },
-)
+bindEasterEggKey('ArrowUp', 'arrowup')
+bindEasterEggKey('ArrowRight', 'arrowright')
+bindEasterEggKey('ArrowLeft', 'arrowleft')

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4f51ee and d02f00d.

📒 Files selected for processing (1)
  • app/components/Package/WeeklyDownloadStats.vue

@whitep4nth3r
Copy link
Contributor

I like it :D

@danielroe danielroe added this pull request to the merge queue Mar 3, 2026
Merged via the queue into npmx-dev:main with commit b9f18da Mar 3, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants